<template>
  <div class="search">
    <div>
      <el-button size="small" @click="submit">查询</el-button>
      <el-button size="small">详情</el-button>
    </div>
    <el-form ref="form" :model="ruleForm" :rules="rules">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-form-item label="身份证号码：" prop="code" label-width="100px">
            <el-input v-model="ruleForm.code" style="max-width:180px;"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="地区：">
            <el-cascader :options="options" v-model="selectedOptions" @change="handleChange"></el-cascader>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="人员类别：">
            <el-select v-model="ruleForm.man" placeholder style="max-width:180px;">
              <el-option v-for="item in manOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import utils from '@/utils';
import areas from '@/utils/area';
const address = areas.address;
export default {
  name: 'keyPersonSearch',
  props: ['params'],
  data() {
    return {
      options: address,
      selectedOptions: [],
      props: {
        value: 'label',
        children: 'cities'
      },
      ruleForm: {
        code: '',
        man: '',
        area: ''
      },
      rules: {
        code: [
          { pattern: utils.regRule.idCard, message: '身份证格式不正确', trigger: 'blur' }
        ]
      },
      manOptions: [
        { label: '涉稳人员', value: '涉稳人员' },
        { label: '执法办案打处', value: '执法办案打处' },
        { label: '七类重点人员', value: '七类重点人员' },
        { label: '交通涉案人员', value: '交通涉案人员' }
      ]
    };
  },
  methods: {
    handleChange(arry) {
      console.log(arry);
      this.ruleForm.area = arry.join('-');
    },
    submit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          alert('submit!');
          this.$emit('getKeyPersonList', this.ruleForm);
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    }
  }
};

</script>
<style lang="scss" scoped>
</style>
